// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SourceFile

package com.sgame.android.network;

import com.sgame.android.MLog;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URI;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.protocol.HttpContext;

// Referenced classes of package com.mobage.ww.android.network:
//            b, HttpRequest

public final class AsyncHttpRequest
    implements Runnable
{

    public AsyncHttpRequest(AbstractHttpClient httpclient, HttpContext httpcontext, HttpUriRequest httpurirequest, AsyncHttpResponseHandler b1, HttpRequest httprequest)
    {
    	mHttpClient = httpclient;
    	mHttpContext = httpcontext;
        mUriRequest = httpurirequest;
        mResponseHandler = b1;
        mHttpRequest = httprequest;
        mErrorCount = 0;
    }

    public final void run()
    {
    	try
    	{
            if(mResponseHandler != null)
            	mResponseHandler.sendMessage2();
            boolean ret = true;
            Object obj2 = null;
            HttpRequestRetryHandler httprequestretryhandler = mHttpClient.getHttpRequestRetryHandler();
            mErrorCount = 0;
            do
            {
                if(!ret)
                    break;
                try
                {
                    if(mUriRequest != null && mHttpContext != null)
                    {
                        System.currentTimeMillis();
                        (new StringBuilder("Sending ")).append(mUriRequest.getURI() != null ? mUriRequest.getURI().toString() : "null").toString();
                        obj2 = mHttpClient.execute(mUriRequest, mHttpContext);
                    } else
                    {
                        throw new RuntimeException("Unhandled state while making request in AsyncHttpRequest");
                    }
                    if(mResponseHandler != null)
                    	mResponseHandler.getHttpEntity(((org.apache.http.HttpResponse) (obj2)));
                    break;
                }
                // Misplaced declaration of an exception variable
                catch(IOException ex)
                {
                	ret = httprequestretryhandler.retryRequest(ex, ++mErrorCount, mHttpContext);
                    continue;
                }
                catch(NullPointerException ex)
                {
                    obj2 = new IOException((new StringBuilder("NPE in HttpClient")).append(ex.getMessage()).toString());
                    ret = httprequestretryhandler.retryRequest(((IOException) (obj2)), ++mErrorCount, mHttpContext);
                }
            } while(true);
            //(nullpointerexception = new ConnectException()).initCause(((Throwable) (obj2)));
        }
    	catch(Exception ex)
    	{
            if(mResponseHandler != null)
            {
            	mResponseHandler.sendMessage3();
                return;
            }
            MLog.d("AsyncHttpRequest", "Uncaught exception in AsyncHttpRequest", ((Throwable) (ex)));
            throw new RuntimeException(((Throwable) (ex)));
    	}
    }

    private final AbstractHttpClient mHttpClient; //a
    private final HttpContext mHttpContext; //b
    private final HttpUriRequest mUriRequest; //c
    private final AsyncHttpResponseHandler mResponseHandler; //d
    private final HttpRequest mHttpRequest; //e
    private int mErrorCount; //f
    private final boolean g = false;
}
